<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Observaciones
 *
 * @author maospina
 */
class Observaciones {
    //put your code here
    private $dnsoid;
    private $hisoid;
    private $observacion;
    private $fecobserva;
    private $estado;
    
    function __construct($dnsoid, $hisoid, $observacion, $fecobserva, $estado) {
        $this->dnsoid = $dnsoid;
        $this->hisoid = $hisoid;
        $this->observacion = $observacion;
        $this->fecobserva = $fecobserva;
        $this->estado = $estado;
    }
    
    public function getDnsoid() {
        return $this->dnsoid;
    }

    public function setDnsoid($dnsoid) {
        $this->dnsoid = $dnsoid;
    }

    public function getHisoid() {
        return $this->hisoid;
    }

    public function setHisoid($hisoid) {
        $this->hisoid = $hisoid;
    }

    public function getObservacion() {
        return $this->observacion;
    }

    public function setObservacion($observacion) {
        $this->observacion = $observacion;
    }

    public function getFecobserva() {
        return $this->fecobserva;
    }

    public function setFecobserva($fecobserva) {
        $this->fecobserva = $fecobserva;
    }

    public function getEstado() {
        return $this->estado;
    }

    public function setEstado($estado) {
        $this->estado = $estado;
    }

    
    function insertarObs(){
        
        include_once '../../controlador/php/conexion/Conexion.php';
        
        session_start();
        
        $con = new Conexion();
        
        $insert = "insert into dnobshisto(dnsoid,hisoid,observacion,fechobserva,estado,usu_oid)values(".$this->dnsoid.",".$this->hisoid.",'".$this->observacion."',GETDATE(),".$this->estado.",".$_SESSION['usuario'].")";
        $con->query($insert);
        
        print_r(json_encode(array('respuesta'=>$this->dnsoid)));
        
        $con->cerrarConexion();
        
    }
    
    function editarObs(){
        
        include_once '../../controlador/php/conexion/Conexion.php';
        
        $con = new Conexion();
        
        $update = "update dnobshisto
                   set observacion = '".$this->observacion."',
                       fechobserva = GETDATE(),
                       estado = 1
                   where dnsoid = ".$this->dnsoid." and hisoid = ".$this->hisoid;
        $con->query($update);
        
        print_r(json_encode(array('respuesta'=>$this->dnsoid)));
        
        $con->cerrarConexion();
        
    }
    
    function editarObs2(){
        
        include_once '../../controlador/php/conexion/Conexion.php';
        
        $con = new Conexion();
        
        $update = "update dnobshisto
                   set estado = 2
                   where hisoid =".$this->hisoid." and dnsoid = ".$this->dnsoid;
        $con->query($update);
        
        $con->cerrarConexion();
        
    }

    
}

?>
